<include file="header2"/>
<div class="wraper">
    <header class="text-center font-white font-16">
        <div class="back iconfont icon-back"></div>
        审核通过
    </header>
    <volist name="num" id="vo">
        <div class="box margin-t12 add-center">
            <div class="list flex">
                <select name="" class="select flex-1 font-gray2 add_car">
                    <option value="0">请选择车辆</option>
                    <volist name="carlist" id="vo">
                        <option value="{BEESCRM:$vo.car_id}">{BEESCRM:$vo.car_code}</option>
                    </volist>
                </select>
                <div class="iconfont icon-xiala font-gray"></div>
            </div>
            <div class="list flex">
                <select name="" class="select flex-1 font-gray2 add_driver">
                    <option value="0">请选择驾驶员</option>
                    <volist name="driverlist" id="v1">
                        <option value="{BEESCRM:$v1.driver_id}">{BEESCRM:$v1.realname}</option>
                    </volist>
                </select>
                <div class="iconfont icon-xiala font-gray"></div>
            </div>
        </div>
    </volist>
    <a  type="button" class="submit text-center font-16" id="add_submit">提交</a>
</div>
<input type="hidden" value="{BEESCRM:$order_id}" id="order_id">
<include file="footer"/>
<script>
    $('#add_submit').click(function(){
        var conf_id = {BEESCRM:$conf_id};
        var order_id = $('#order_id').val();
        var car_id = new Array();
        $('.add_car').each(function(i){
            car_id.push($(this).val());
        });
        var driver_id = new Array();
        $('.add_driver').each(function(i){
            driver_id.push($(this).val());
        });
        $.ajax({
            url:"/base/OfficialCar/doSave/conf_id/"+conf_id,
            data:{order_id:order_id,car_id:car_id.join(','),driver_id:driver_id.join(',')},
            type:'post',
            dataType:'json',
            success:function(result){
                if(result.status == "F"){
                    fm.alert(result.message);
                }else if(result.status == "S"){
                    fm.alert(result.message);
                    setTimeout(reload(),2000);
                }
            }
        });
    });

    function reload(){
        var conf_id = {BEESCRM:$conf_id};
        window.location.href="/base/OfficialCar/dispatcher/conf_id/"+conf_id;
    }
</script>

